package Eyjafjalla.relic;

import Eyjafjalla.action.DrawToCloudAction;
import Eyjafjalla.action.GoodFriendAction;
import Eyjafjalla.helper.StringHelper;
import basemod.abstracts.CustomRelic;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import com.megacrit.cardcrawl.ui.panels.EnergyPanel;

public class RainbowUrn extends CustomRelic {

    public static final String ID = "eyjafjalla:RainbowUrn";
    boolean canPulse = false;

    public RainbowUrn(){
        super(ID, ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,false)),ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,true)),RelicTier.COMMON,LandingSound.SOLID);
    }

    public void onPlayerEndTurn() {
        canPulse = false;
        if (EnergyPanel.getCurrentEnergy() > 0) {
            this.flash();
            this.stopPulse();
            this.addToTop(new GoodFriendAction(true,1));
            this.addToTop(new GoodFriendAction(true,1));
            this.addToTop(new RelicAboveCreatureAction(AbstractDungeon.player, this));
        }

    }

    public void atTurnStart() {
        canPulse = true;
        if (EnergyPanel.getCurrentEnergy() > 0) {
            this.beginLongPulse();
        }
    }

    @Override
    public void update() {
        if(canPulse){
            if(pulse&&EnergyPanel.getCurrentEnergy()==0){
                this.stopPulse();
            }
        }
        super.update();
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new RainbowUrn();
    }
}



